(function($){
    /*模板引擎设置*/
    _.templateSettings = {
        interpolate: /\{\{(.+?)\}\}/g
    };


    $.log=function(content,title,format){
        if (typeof content == 'object') {
            content = JSON.stringify(content, null, '\t');
            if (format) {
                content = content.replace(/\n/g, '<br/>').replace(/\t/g, ' &nbsp; &nbsp; ');
            }
            if(arguments.length>3){
                var keywords = Array.prototype.slice.call(arguments, 3);
                for(var i=0;i<keywords.length;i++){
                    var keyword = keywords[i];
                    content=content.replace(new RegExp('"'+keyword+'"',"g"),'<span style="background:yellow">"'+keyword+'"</span>');
                }
            }
        }

        // 为消息增加点击事件，开始时折叠消息
        var $msg = $('<p/>').addClass('shortMsg').click(function() {
            $(this).toggleClass('shortMsg');
        });


        var _title=title||">>";
        $('<span/>').css('color', 'red').text(_title + ' ').appendTo($msg);
        $('<span/>').html(content).appendTo($msg);
        $msg.appendTo('#debugInfo > div');
    };

    $("#reloadPage").on("click",function(){
        location.reload();
    });

})(Zepto);

(function($){
    $(document).ready(function () {
         var Student=Backbone.Model.extend({
             defaults:{
                 Code:"",
                 Name:"",
                 Score:""
             },
             idAttribute:"Code"
         });

        var stuModels=[
            {
                Code:"10104",
                Name:"wong",
                Score:"500"
            },

            {
                Code:"10105",
                Name:"jian",
                Score:"330"
            },

            {
                Code:"10106",
                Name:"beji",
                Score:"510"
            }
        ];

        var newModels=[
            {
                Code:"10107",
                Name:"ysw",
                Score:"520"
            },
            {
                Code:"10108",
                Name:"HHJ",
                Score:"512"
            },
            {
                Code:"10109",
                Name:"JJ",
                Score:"542"
            }
        ];

        var StuList=Backbone.Collection.extend({
            model:Student,
            good:function(){
                return this.filter(function(stu){
                    return stu.get("Score")>300;
                })
            }
        });

        var stus=new StuList(stuModels);
        stus.unshift(newModels[1]);
        stus.add(newModels[0],{at:2});
        stus.push(newModels[2]);

        for(var i= 0,len=stus.models.length;i<len;i++){
            $.log(stus.models[i].toJSON());
        }

        console.log(stu)


    });
})(Zepto);